package com.zhiyou100.entity;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Exam   implements Serializable{
     private static SimpleDateFormat  sdf=new SimpleDateFormat("yyyy-MM-dd");
      private Integer eid;
      private String ename;
      private Date   etime;
       private String etimeStr;
       private String eurl;//考试的题目文本
      public Date getEtime() {
          if(etimeStr==null&&etime==null){
              return null;
          }
        if(etime==null){
            try {
                etime=sdf.parse(etimeStr);
            }catch (Exception e){
                throw new RuntimeException(e);
            }
        }
        return etime;
     }

    public void setEtime(Date etime) {
        this.etime = etime;
        if(etime==null){return;}
        etimeStr=sdf.format(etime);
    }
    public String getEtimeStr() {
        if(etimeStr==null&&etime==null){
            return null;
        }
        if(etimeStr==null&&etimeStr.trim().length()==0){
            etimeStr=sdf.format(etime);
        }
        return etimeStr;
    }

    public String getEurl() {
        return eurl;
    }

    public void setEurl(String eurl) {
        this.eurl = eurl;
    }

    public void setEtimeStr(String etimeStr) {
        this.etimeStr = etimeStr;
        if(etimeStr==null){return;}
        try {
            etime=sdf.parse(etimeStr);
        }catch (Exception e){
            throw new RuntimeException(e);
        }

    }

    @Override
    public String toString() {
        return "Exam{" +
                "eid=" + eid +
                ", ename='" + ename + '\'' +
                ", etime=" + etime +
                ", etimeStr='" + getEtimeStr() + '\'' +
                '}';
    }

    public Integer getEid() {
        return eid;
    }

    public void setEid(Integer eid) {
        this.eid = eid;
    }

    public String getEname() {
        return ename;
    }

    public void setEname(String ename) {
        this.ename = ename;
    }


}
